package com.example.train_operate.controller;
import com.example.train_operate.entity.Experiment;
import com.example.train_operate.service.ExperimentService;
import com.example.train_operate.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@Api(tags = "系统实验任务接口")
@RequestMapping("/experiment")
public class ExperimentController {

    @Resource
    private ExperimentService experimentService;

    /**
     * 添加系统实验任务
     * @param experiment
     * @return
     */
    @PostMapping("/addExperiment")
    @ApiOperation("添加系统实验任务")
    public Result addExperiment(@RequestBody Experiment experiment){
        return experimentService.addExperiment(experiment);
    }

    /**
     * 根据id查询系统实验任务
     * @param experimentId
     * @return
     */
    @GetMapping("/getExperimentById/{experimentId}")
    @ApiOperation("根据id查询系统实验数据")
    public Result getExperimentById(@PathVariable Integer experimentId){
        return experimentService.getExperimentById(experimentId);
    }

    /**
     * 修改系统实验任务
     * @param experiment
     * @return
     */
    @PutMapping("/updateExperiment")
    @ApiOperation("修改系统实验数据")
    public Result updateExperiment(@RequestBody Experiment experiment){
        return experimentService.updateExperiment(experiment);
    }
}
